-
Notifications
You must be signed in to change notification settings - Fork 370
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
upcoming: [DI-19328] - Added capability to save & retrieve CloudPulse user preferences #10625
Conversation
@nikhagra Before we review this PR, can we get a complete PR description? Unless there are no visual changes, the Preview section is helpful to see the UI differences at a glance. Including steps in How to test allows us to verify we can reproduce your changes as expected and edge cases have been accounted for. |
@mjac0bs Yes working on it |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I worry that /v4/profile/preferences
won't be a good long term solution for storing this stuff.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should be able to use our React Query data layer for anything related to user preferences. (packages/manager/src/queries/profile/preferences.ts
). We try to use that instead of interfacing with @linode/api-v4
functions directly
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To add to Banks, here's reference point in our docs: https://linode.github.io/manager/development-guide/05-fetching-data.html#react-query
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!! for the suggestion. We will take this up as part of enhancements later to use React Query Data layer via https://track.akamai.com/jira/browse/DI-19503 as in Q3 we have a commitment for beta with minimum functionalities. Hope this is fine for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kmuddapo Use of React Query is something we'd need to see in this PR to get it merged, rather than later. Using direct api-v4 functions is rare in our codebase, and it may be acceptable on a one-off basis, but our best practice is to use RQ almost all the time -- this offers caching benefits, helps us manage states (loading, errors), as well as provides overall consistency in code. (See here for our section of documentation on this.) In this PR, even with debouncing, we'd be making several requests to /profile/preferences
and we should be leveraging the RQ cache.
@nikhagra Please update to use React Query here in place of the api-v4 functions, and let us know if you run into any questions on implementing that switch.
Coverage Report: ✅ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR, @nikhagra. Left some comments throughout, and I do agree with Banks in thinking that a user's profile preferences doesn't feel like the best place to store CloudPulse prefs... were there other options discussed?
As far as the UI: I am seeing disabled fields for the dashboard, region, and resources. Should I be testing this with additional configurations on my account? I can interact with the fields if I turn on the Mock Service Worker via our dev tools, but that won't save the user's values.
packages/manager/.changeset/pr-10625-upcoming-features-1719830617170.md
Outdated
Show resolved
Hide resolved
packages/manager/src/features/CloudPulse/Utils/CloudPulseConstants.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's rename this file utils.ts
to remain consistent with convention in the codebase.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed the case of file name to camel case because in future more util files will be added for different functionalities
packages/api-v4/.changeset/pr-10625-upcoming-features-1719830627087.md
Outdated
Show resolved
Hide resolved
packages/manager/src/features/CloudPulse/shared/CloudPulseDashboardSelect.tsx
Show resolved
Hide resolved
packages/manager/src/features/CloudPulse/shared/CloudPulseRegionSelect.tsx
Outdated
Show resolved
Hide resolved
packages/manager/src/features/CloudPulse/shared/CloudPulseDashboardSelect.tsx
Outdated
Show resolved
Hide resolved
packages/manager/src/features/CloudPulse/shared/CloudPulseRegionSelect.tsx
Outdated
Show resolved
Hide resolved
packages/manager/src/features/CloudPulse/shared/CloudPulseResourcesSelect.tsx
Outdated
Show resolved
Hide resolved
Currently the endpoint for Dashboard component is not yet ready to use, that's why we have to use mock data for now. |
…617170.md Co-authored-by: Mariah Jacobs <[email protected]>
a546c49
to
afc40fc
Compare
@nikhagra I have the same question as @mjac0bs. The first testing instruction you have provided is: "Select values from global filter drop-downs." Yet all I see is disabled fields: In your comment above you acknowledge that we must use mock data. If that is the case, please include steps to configure mock data appropriately in your testing instructions. |
@jcallahan-akamai I've updated the testing instructions in the description. Since we can only test now as mock user, so preferences won't be saved for mock user but we can verify the same from network tab for preferences API call on value change. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for addressing some initial feedback @nikhagra. Testing instructions are looking good now - appreciate the update. I confirmed the network requests and responses upon updating /profile/preferences
.
Two more bits of feedback:
-
Please see my comment about React Query.
-
I am still somewhat concerned about storing these preferences in a user's profile preferences, rather than that information being returned from an
aclp
endpoint. Do we anticipate there being additional data stored in user preferences for CloudPulse?
As is, it feels out of place. For context, /profile/preferences
is generally used to store things like what theme (light/dark/system) colors to use, or whether banners have been dismissed.
|
packages/manager/src/features/CloudPulse/shared/CloudPulseRegionSelect.tsx
Outdated
Show resolved
Hide resolved
packages/manager/src/features/CloudPulse/shared/CloudPulseResourcesSelect.tsx
Outdated
Show resolved
Hide resolved
packages/manager/src/features/CloudPulse/shared/CloudPulseResourcesSelect.tsx
Outdated
Show resolved
Hide resolved
@nikhagra Thanks for keeping up with all the PR feedback, I left some comments myself. It's almost there! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Nikhil, approving pending a couple smaller bits of feedback are addressed, like naming the hooks as such and cleaning up another any
.
Also left a few non-blocking nits about JSDocs comments, linter warnings, etc.
packages/manager/src/features/CloudPulse/Utils/UserPreference.ts
Outdated
Show resolved
Hide resolved
packages/manager/src/features/CloudPulse/Utils/UserPreference.ts
Outdated
Show resolved
Hide resolved
packages/manager/src/features/CloudPulse/Utils/UserPreference.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice to have: JSDocs comments are useful to include for custom hooks and utils. useRestrictedGlobalGrantCheck and usePagination are a couple examples of where we do this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure
packages/manager/src/features/CloudPulse/shared/CloudPulseResourcesSelect.tsx
Outdated
Show resolved
Hide resolved
packages/manager/src/features/CloudPulse/shared/CloudPulseResourcesSelect.tsx
Outdated
Show resolved
Hide resolved
Confirmed the only test failure is on |
Description 📝
Added a feature to save the users global filter selection to preferences & load it back when user revisit the page.
Changes 🔄
Added UserPreference utility file to handle all the preferences related operations
Modified all the global filter components to by default get selected with preferences value, if any present.
Target release date 🗓️
Please specify a release date to guarantee timely review of this PR. If exact date is not known, please approximate and update it as needed.
Preview 📷
Include a screenshot or screen recording of the change
💡 Use
<video src="" />
tag when including recordings in table.How to test 🧪
Note: Since Dashboards api is not ready to use, therefore have to enable mock services for testing. But with mock services preferences will not be saved properly, that's why it can be verified from the network tab that preferences api call is going on initial loading of the CloudPulse page to retrieve the saved preferences as well as on changing of every global filter value to update it.
As an Author I have considered 🤔
Check all that apply